home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
cvt100.zip
/
CVT100.DOC
< prev
next >
Wrap
Text File
|
1988-08-06
|
17KB
|
727 lines
CVT100, Terminal Emulator for Turbo C
VT100, A Simple VT100 Emulator in Turbo C 1.5
By Jerry Joplin CIS [70441,2627]
CVT100, Terminal Emulator for Turbo C
Overview
CVT100 is a simple VT100 emulator programed exclusively
in Turbo C 1.5. *All* of the code is in Turbo C. There are
no assembler routines or functions requiring an assembler.
All of the code is contained in 7 modules. These are:
comio.c communications functions
cvt100.c terminal emulator main
fileio.c file manipulation functions
keyio.c keyboard functions
vidio.c video functions
vtsetup.c setup functions
vttio.c terminal output interpretation functions
The program was designed with several objectives in mind.
1) To provide a public domain source for a VT100
emulator written in Turbo C code that was easy to
understand and modify,
2) To show the power and flexibility of Turbo C without
having to resort to assembly language routines,
3) To aid (however slightly) in the development of a C
version of Kermit for MS DOS systems,
4) To provide a terminal emulator that takes a very
small amount of memory and is capable of running in
a well behaved window in Windows or DesqView (less
than 40k).
CVT100, Terminal Emulator for Turbo C
Operation
The terminal emulator is menu driven. The top line of
the terminal screen is reserved as a status line. A list of
choices is displayed on the status line for setting the
various parameters concerning the different aspects of the
programs operation.
Function Key F5: This activates the Communications menu
setup. Here the COM port is
established along with its associated
baud rate, parity, data bits
and stop bits.
Function Key F6: This key will activate the Video setup
menu. Here the screen colors can be
set and the "snow" inhibit mode can be
set.
Function Key F7: This key when pressed enters the
keyboard setup menu. Here the
program's interpretation of the
backspace key can be set. The
keyboard can be programed to produce a
'key-click' and the state of the
keypad can be defined.
Function Key F8: An Emulation menu becomes active when
F8 is pressed. Here the many mode
settings for the emulator may be set.
These include origin mode,
insert/replace mode, auto wrap mode,
new line mode, cursor visibility,
background video attributes and the
logical screen width.
Function Key F9: Function key F9 brings up a File menu.
The current settings for the terminal
can be saved in an initialization file
that is read when the program is
started. Also a log of incoming
characters can be controlled.
Function Key F10: This is used as the exit key. When
pressed this will close any open log
files and exit.
CVT100, Terminal Emulator for Turbo C
Communications
Characters are received via receiver interrupts
generated by the UART. The interrupt service routine (ISR)
for the incoming characters is a function of type interrupt
for Turbo C. Although any serious communications program
should have the transmission interrupts in assembler, this
program has been tested at 19,200 baud on a plain vanilla
4.77 Mghz PC with no loss of characters.
An XON/XOFF 'handshake' is used to control the flow of
characters to and from the host. An XOFF is transmitted to
the host when 75% of the communications circular buffer is
full. This will tell the host to stop transmitting
characters until an XON is transmitted to it. When the
buffer is back down to 25% full an XON will be sent to the
host signaling it that it is okay to begin transmission
again.
When an XOFF has been received from the host this
program will delay for a short period of time before sending
a character to check for an XON being sent. Note that the
character will still be transmitted if the wait period passes
with no XON being received.
CVT100, Terminal Emulator for Turbo C
Video
Most video manipulations are done by reading and writing
directly to the screen's memory. This made it necessary to
provide "snow" protection on CGA systems, but much less time
is wasted on writing characters and attributes than using the
BIOS.
A check is done before each video memory access to
detect a control program such as Windows, DesqView, or
TopView. Each of these control programs will keep a video
"shadow" buffer for processes currently executing. The
address of this buffer can be queried and output directed to
this buffer instead of the actual screen. This will let
CVT100 run in a well behaved window in these environments.
There are several problems with the video system. A few
of the colors (Yellow foreground) do not work properly with
the emulation. The program tries to juggle various
attributes defined by the host's control commands and tends
to lose the defined color in the process. Also changing the
screen foreground and background colors may or may not work
during program execution. This is due to the fact that the
software tries to retain the contents of the terminal screen
while making the color changes and again may get confused by
defined attributes. To get around this problem, exit the
emulator and re-execute it. The new colors will take effect
properly upon video initialization.
CVT100, Terminal Emulator for Turbo C
Keyboard
The most controversial part of any terminal emulator
will usually be the setup of the IBM PC keyboard to try and
match the Digital Equipment Corporation VT keypad. Not an
easy task. This program tries to map as closely as possible
the keypad for an IBM PC to a DEC VT keypad. The results
a